var HomepageFavorite = {
	// 加入收藏
	favorite : function favorite(url, title) {
		var ctrl = (navigator.userAgent.toLowerCase()).indexOf('mac') != -1 ? 'Command/Cmd' : 'CTRL';
		if (document.all) {
			window.external.addFavorite(url, title);
		} else if (window.sidebar) {
			window.sidebar.addPanel(title, url, "");
		} else {
			alert('您可以尝试通过快捷键' + ctrl + ' + D 加入到收藏夹~');
		}
	},

	// 设为首页
	homepage : function homepage(obj, url) {
		//$("#sethomepage").attr('target', 'blank');
		try {
			obj.style.behavior = "url(#default#homepage)";
			obj.setHomePage(url);
		} catch (e) {
			if (document.all) {
				document.body.style.behavior = "url(#default#homepage)";
				document.body.setHomePage(url);
			} else if (window.sidebar) {
				if (window.netscape) {
					try {
						netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
					} catch (e) {
						alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
						//$("#sethomepage").attr('href', 'http://help.sinbong.com/');
					}
				}
				var prefs = Components.classes["@mozilla.org/preferences-service;1"]
						.getService(Components.interfaces.nsIPrefBranch);
				prefs.setCharPref('browser.startup.homepage', url);
			} else {
				alert('您的浏览器不支持自动设置首页,使用浏览器菜单或在浏览器地址栏输入“chrome://settings/browser”手动设置!');
				//$("#sethomepage").attr('href', 'http://help.sinbong.com');
			}
		}
	}
};
